#include "PclViewTools.h"
// OpenCV 库
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;

int main(){
    // string path = "/home/de/testCode/image_hd _depth.png";
    string path = "/home/de/testDatamnist/image_hd_depth_2.png";
    string PcdPath = "/home/de/testCode/PCDFILE/smallROIDepth.pcd";
    cv::Mat depth_ = cv::imread(path, cv::IMREAD_GRAYSCALE);
    cv::Mat depth;

    if (depth_.depth() == CV_32F)
        depth_.convertTo(depth, CV_16UC1, 1000.0);
    else{
        depth_.convertTo(depth, CV_16UC1, 1000.0);
    }

    // cv::Mat InitColorImg = imread("/home/de/testDatamnist/image_hd_color_2.png");

    PclViewTools*  Pclviewer = new PclViewTools();
    // PointCloud::Ptr pcloud(new PointCloud);
    // pcl::PointCloud<PointT>::Ptr pcloud(new pcl::PointCloud<PointT>);
    string CloudPath = "/home/de/Downloads/icbin_bop19/models/obj_000002.ply";
    if (pcl::io::loadPLYFile<pcl::PointXYZ>(CloudPath, *pcloud) ==-1) //* load the file 
    {
        PCL_ERROR("Couldn't read file test_pcd.pcd \n");
        system("PAUSE");
        return (-1);
	}
    PCL_INFO("Load ply is ok");
    pcl::visualization::CloudViewer viewer("Simple Cloud Viewer");
	viewer.showCloud(pcloud); 	// viewer.runOnVisualizationThreadOnce(viewerOneOff);
	while (!viewer.wasStopped());
	system("pause");


    // Pclviewer->Visual3DTool(pcloud);
    // PclViewTools* PclView = new PclViewTools();
    // PclView->DepthToCloudPCD(depth, PcdPath);
    // PclView->VisualTool(PcdPath);
    delete Pclviewer;
    return 0;
}